@extends('admin.layout.open')

@section('content')
    <div class="breadcrumbs ace-save-state" id="breadcrumbs">
        <ul class="breadcrumb">
            <li>
                <i class="ace-icon fa fa-home home-icon"></i>
                <span >首页</span>
            </li>
            <li>
                <span >会员管理</span>
            </li>
            <li ><span >系统消息列表</span></li>
            <li class="active"><a href="{{ url('admin/message_index') }}">选择用户</a></li>
        </ul><!-- /.breadcrumb -->

        <div class="nav-search" id="nav-search">
            <form class="form-search">
		<span class="input-icon">
		{{--<input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" />--}}
			{{--<i class="ace-icon fa fa-search nav-search-icon"></i>--}}
		</span>
            </form>
        </div><!-- /.nav-search -->
    </div>
    <form class="form-search" action="/admin/select_user" method="get">
        <span class="page-content" style="background: #E4E6E9">账号：</span>
        <span class="input-icon">
        <input type="hidden" name="_token" value="{{csrf_token()}}"/>
		<input type="text"  name="account" value="{{$account}}" class="nav-search-input"  autocomplete="off" />
		</span>
        <span class="page-content" style="background: #E4E6E9">手机号：</span>
        <input type="text"  name="phone" value="{{$phone}}" class="nav-search-input" autocomplete="off" />
        <span class="input-icon">
        <span class="page-content" style="background: #E4E6E9">邮箱：</span>
        <input type="text"  name="email" value="{{$email}}" class="nav-search-input" autocomplete="off" />
        <span class="input-icon">
        <button class="btn btn-info " style="border-color: #E4E6E9;" type="submit" >
            查找
        </button>
        </span>
        </span>
    </form>
    <div class="page-content">
        <div class="row">
            <div class="col-xs-12">
                <!-- PAGE CONTENT BEGINS -->
                <div class="row">
                    <div class="col-xs-12">
                        <div class="clearfix">
                            <div class="pull-right tableTools-container"></div>
                        </div>
                        <div class="table-header">
                            {{--<a href="{{ url('admin/message_create') }}">--}}
                                {{--<i class="menu-icon fa fa-plus orange"></i>--}}
                                {{--<span class="menu-text orange"> 添加系统消息 </span>--}}
                            {{--</a>--}}
                        </div>

                        <!-- div.table-responsive -->

                        <!-- div.dataTables_borderWrap -->
                        <div>
                            <table id="dynamic-table" class="table table-striped table-bordered table-hover">
                                <thead>
                                <tr>
                                    <th>序号</th>
                                    <th>账号</th>
                                    <th>昵称</th>
                                    <th>手机号</th>
                                    <th>邮箱</th>
                                    <th class="hidden-480">添加时间</th>
                                    <th></th>
                                </tr>
                                </thead>


                                <tbody>
                                {{--@if($list->isEmpty())--}}
                                    {{--<tr>--}}
                                        {{--<td>--}}
                                            {{--没有数据--}}

                                        {{--</td>--}}
                                    {{--</tr>--}}
                                {{--@endif--}}
                                @foreach($list as $item)
                                <tr>
                                    <td>{{$page_num++}}</td>
                                    <td>{{$item['account']}}</td>
                                    <td>{{$item['nickname']}}</td>
                                    <td>{{$item['phone']}}</td>
                                    <td>{{$item['email']}}</td>
                                    <td>{{$item['created_at']}}</td>
                                    <td>

                                            <label>
                                                <input name="userids[]" onclick="saveId('{{$item["id"]}}','{{$item["account"]}}',this)" value="{{$item['id']}}" class="ace" type="checkbox">
                                                <span class="lbl"> </span>
                                            </label>
                                </tr>
                                @endforeach
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <!-- PAGE CONTENT ENDS -->
            </div><!-- /.col -->

            <div class="modal-footer no-margin-top">
                @if(empty($url_data))
                    {{ $list->links() }}
                @else
                    {{$list->appends($url_data)->links() }}
                @endif
            </div>

        </div><!-- /.row -->
    </div><!-- /.page-content -->
    <!--[if !IE]> -->
    <script src="{{ asset('/admin/js/jquery-2.1.4.min.js') }}"></script>

    <!-- <![endif]-->

    <!--[if IE]>
    <script src="assets/js/jquery-1.11.3.min.js"></script>
    <![endif]-->
    <script>
        $(function(){
            var select_ids = JSON.parse(sessionStorage.select_ids);
            var inputs = $("input[name='userids[]']");
            for(var i in inputs){
                var uid = inputs[i].value;
                if(select_ids[uid]){
                    inputs[i].checked = true;
                }
            }

        })
        function saveId(id,account,obj) {
            var select_ids = sessionStorage.select_ids;
            if(obj.checked){//添加
                if(select_ids){
                  var ids_obj = JSON.parse(select_ids);
                  if(ids_obj[id]){
                      return;
                  }
                  ids_obj[id] = account;

                }else{
                    var ids_obj = {};
                    ids_obj[id] = account;
                }
                sessionStorage.select_ids = JSON.stringify(ids_obj);
            }else{//删除
                if(select_ids){
                    var ids_obj = JSON.parse(select_ids);
                    delete ids_obj[id];
                    sessionStorage.select_ids = JSON.stringify(ids_obj);

                }
            }

        }

    </script>
@endsection
